﻿Imports Aricie.DNN.UI.Controls
Imports Lucene.Net.Search
Imports Aricie.ComponentModel
Imports Aricie.DNN.Modules.LuceneSearch.Business


Namespace Aricie.DNN.Modules.LuceneSearch.UI.FilteringControls
    ''' <summary>
    ''' Tentative de clarifier comment fonctionnent les filtres
    ''' </summary>
    ''' <remarks></remarks>
    Public MustInherit Class SearchFilteringControl
        Inherits SimpleFilteringControl

        Public Property QueryMode() As QueryMode

        Public Overrides Function GetFilter() As Business.LuceneFilterQuery
            Dim result As New LuceneFilterQuery()
            If (QueryMode = UI.QueryMode.Filter) Then
                result.FilterQuery = SetFilter()
            Else
                result.SearchQuery = SearchValue()
            End If
            Return result
        End Function

        Public Overrides Function ParseFilter(objFilter As Business.LuceneFilterQuery) As Boolean
            If (QueryMode = UI.QueryMode.Filter) Then
                Return ReadFilter(objFilter.FilterQuery)
            Else
                Return ReadSearchParams(objFilter.SearchQuery)
            End If
        End Function

        Public MustOverride Function SearchValue() As String
        Public MustOverride Function ReadSearchParams(searchQuery As String) As Boolean

    End Class
End Namespace